package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.ShoppingCart;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {
    List<Setmeal> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);
    @AutoFill(OperationType.INSERT)
    void add(Setmeal setmeal);
    @Delete("delete from setmeal where id = #{id}")
    void deletebyId(Long id);
    @Select("select * from setmeal where id = #{id}")
    Setmeal getbyId(Long id);
    @Select("select count(id) from setmeal where category_id = #{id}")
    int countByDishId(Long id);
    @AutoFill(OperationType.UPDATE)
    void updateById(Setmeal setmeal);
    @Update("update setmeal set status = #{status} where id = #{id}")
    void startOrStop(Integer status, Long id);
    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> list(Long categoryId);
    @Select("select sd.naem sd.copies d.image d.description from setmeal_dish sd left join dish d on sd.dish_id = d.id where sd.setmeal_id = #{id}")
    List<DishItemVO> getdishItemVO(Long id);

    Setmeal getbysetmealId(Long setmealId);
    //根据条件统计套餐数量
    Integer countByMap(Map map);
}
